import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormControl, FormGroup} from '@angular/forms';
import {FormValidatorService} from 'great-ngform';

@Component({
  selector: 'app-integer',
  templateUrl: './integer.component.html',
  styleUrls: ['./integer.component.less']
})
export class IntegerComponent implements OnInit {

  form: FormGroup;

  constructor(
    private fb: FormBuilder,
    private validator: FormValidatorService
  ) {
  }

  ngOnInit() {
    this.form = this.fb.group({
      integer: new FormControl(null, [
        this.validator.integer()
      ]),
      integer2: new FormControl(null, [
        this.validator.integer({min: 18})
      ]),
      integer3: new FormControl(null, [
        this.validator.integer({max: 18})
      ]),
      integer4: new FormControl(null, [
        this.validator.integer({greaterThan: 18})
      ]),
      integer5: new FormControl(null, [
        this.validator.integer({lessThan: 18})
      ]),
      integer6: new FormControl(null, [
        this.validator.integer({length: 2})
      ]),
      integer7: new FormControl(null, [
        this.validator.integer({maxLength: 2})
      ]),
      integer8: new FormControl(null, [
        this.validator.integer({minLength: 2})
      ]),
      integer9: new FormControl(null, [
        this.validator.integer({lessThan: 18, greaterThan: 8})
      ]),
      integer10: new FormControl(null, [
        this.validator.integer({max: 18, min: 8})
      ]),
    });
  }

}
